<?php

namespace common\models\base;

use common\behaviors\ForumBehavior;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\behaviors\BlameableBehavior;
use mootensai\behaviors\UUIDBehavior;

/**
 * This is the base model class for table "registration".
 *
 * @property string $id
 * @property string $invitation_code
 * @property string $character
 * @property string $region
 * @property string $accompanied
 * @property string $dealer
 * @property string $dealer_code
 * @property string $post
 * @property string $name
 * @property string $genter
 * @property string $card_type
 * @property string $card_num
 * @property string $telephone
 * @property string $nationality
 * @property string $email
 * @property string $spare_contact
 * @property string $spare_contact_phone
 * @property string $come_transportation
 * @property string $departure_city
 * @property string $arrival_location
 * @property string $come_flight_number
 * @property string $arrival_time
 * @property string $is_aircraft
 * @property string $back_transportation
 * @property string $arrived_city
 * @property string $departure_location
 * @property string $back_flight_number
 * @property string $departure_time
 * @property string $is_send
 * @property string $dietary_needs
 * @property string $is_ceremony
 * @property string $is_hotel
 * @property string $come_hotel
 * @property string $back_hotel
 * @property string $forum
 * @property string $created_at
 * @property string $updated_at
 * @property string $deleted_at
 * @property string $created_by
 * @property string $updated_by
 * @property string $deleted_by
 * @property integer $status
 */
class Registration extends \common\hayz\db\ActiveRecord
{
    use \mootensai\relation\RelationTrait;

    private $_rt_softdelete;
    private $_rt_softrestore;

    public function __construct(){
        parent::__construct();
        $this->_rt_softdelete = [
            'deleted_by' => \Yii::$app->user->id,
            'deleted_at' => date('Y-m-d H:i:s'),
        ];
        $this->_rt_softrestore = [
            'deleted_by' => 0,
            'deleted_at' => date('Y-m-d H:i:s'),
        ];
    }

    /**
    * This function helps \mootensai\relation\RelationTrait runs faster
    * @return array relation names of this model
    */
    public function relationNames()
    {
        return [
            ''
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['arrival_time', 'character','departure_time', 'come_hotel', 'back_hotel', 'created_at', 'updated_at', 'deleted_at'], 'safe'],
            [['invitation_code', 'region', 'accompanied', 'dealer', 'dealer_code', 'post', 'name', 'genter', 'card_type', 'card_num', 'telephone', 'nationality', 'spare_contact', 'spare_contact_phone', 'come_transportation', 'departure_city', 'back_transportation', 'arrived_city', 'departure_location', 'back_flight_number', 'is_send', 'dietary_needs', 'is_ceremony', 'is_hotel'], 'string'],
            [['email'], 'string', 'max' => 200],
            [['arrival_location'], 'string', 'max' => 45],
            [['come_flight_number', 'is_aircraft', 'created_by', 'updated_by', 'deleted_by'], 'string', 'max' => 32],
            [['status'], 'string', 'max' => 2]
        ];
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'registration';
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '序号',
            'invitation_code' => '邀请码',
            'character' => '角色',
            'region' => '区域',
            'accompanied' => '所属嘉宾',
            'dealer' => '工作单位',
            'dealer_code' => '经销商代码',
            'post' => '职位',
            'name' => '姓名',
            'genter' => '性别',
            'card_type' => '证件类型',
            'card_num' => '证件号码',
            'telephone' => '联系电话',
            'nationality' => '国籍',
            'email' => '邮箱',
            'spare_contact' => '备用联系人',
            'spare_contact_phone' => '备用联系人电话',
            'come_transportation' => '来程交通方式',
            'departure_city' => '来程出发城市',
            'arrival_location' => '来程抵达地点',
            'come_flight_number' => '来程航班号/车次',
            'arrival_time' => '来程抵达时间',
            'is_aircraft' => '是否接机',
            'back_transportation' => '返程交通方式',
            'arrived_city' => '返程抵达城市',
            'departure_location' => '返程出发地点',
            'back_flight_number' => '返程航班号/车次',
            'departure_time' => '返程出发时间',
            'is_send' => '是否送机',
            'dietary_needs' => '饮食特殊需求',
            'is_ceremony' => '是否参加开幕式',
            'is_hotel' => '是否入住指定酒店',
            'come_hotel' => '入住酒店时间',
            'back_hotel' => '离开酒店时间',
            'forum' => '参加论坛',
            'status' => 'Status',
			'created_at' => '创建时间',
			'updated_at' => '最后更新时间',
        ];
    }

    /**
     * @inheritdoc
     * @return array mixed
     */
    public function behaviors()
    {
        return [
            'timestamp' => [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'created_at',
                'updatedAtAttribute' => 'updated_at',
                'value' => new \yii\db\Expression('NOW()'),
            ],
            'blameable' => [
                'class' => BlameableBehavior::className(),
                'createdByAttribute' => 'created_by',
                'updatedByAttribute' => 'updated_by',
            ],
            'uuid' => [
                'class' => UUIDBehavior::className(),
                'column' => 'id',
            ],
//            'forumBehavior' => [
//                'class' => ForumBehavior::className(),
//            ]
        ];
    }


}
